home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- * File: ns_md8lib.js *
- * *
- * Copyright MatchWare A/S *
- * Author: Jens ╪. Nielsen *
- ******************************************************************************/
-
- var canplaysound = false;
- var usecursor = false;
-
- function BrowserInit() {
-
- if ( ! IsNetscape()) return;
-
- window.captureEvents( Event.MOUSEDOWN | Event.MOUSEUP| Event.MOUSEMOVE);
- window.onmousedown = MouseDown;
- window.onmouseup = MouseUp;
- window.onmousemove = MouseMove;
- // Sound check
- if (navigator.javaEnabled()) {
- if (navigator.mimeTypes['audio/midi'] != null) {
- if (navigator.mimeTypes['audio/midi'].enabledPlugin != null)
- canplaysound = true;
- }
- }
- }
-
- //--------------------------------------------------------------
-
- function GetObjLeft( obj) {
-
- return obj.left;
- }
-
- function GetObjTop( obj) {
- return obj.top;
- }
-
- function GetObjWidth( obj) {
-
- if ( obj.document.width)
- return obj.document.width;
- else
- return obj.clip.right - obj.clip.left;
- }
-
- function GetObjHeight( obj) {
- if ( obj.document.height)
- return obj.document.height;
- else
- return obj.clip.bottom - obj.clip.top;
- }
-
- function SetObjPosition( obj,left,top) {
- obj.left = left;
- obj.top = top;
- }
-
- function IsObjVisible( obj) {
- return obj.visibility == "show";
- }
-
- function ShowObject( obj,visible) {
- obj.visibility = visible ? "show" : "hide";
- }
-
- //------------------------------------
-
- var PAGE_ACTION_POST_FIX = "_ns.htm";
-
- //------------------------------------
-
- var specialobj = null;
- var scrolldy = 0;
-
- //--------------------------------------------------------------
-
- function MouseDown( e) {
-
- var layer = FindLayerByPos( e.pageX,e.pageY,document);
- if ( layer != null) {
- clickobj = layer;
- eval( layer.name + "_MouseDown( e,layer);");
- return false;
- }
- return true;
- }
-
- //--------------------------------------------------------------
-
- function MouseUp( e) {
-
- var layer = FindLayerByPos( e.pageX,e.pageY,document);
- if ( layer != null) {
- eval( layer.name + "_MouseUp( e,layer);");
- if ( layer == clickobj) {
- eval( layer.name + "_MouseClick( e,layer); ");
- }
- clickobj = null;
- return false;
- }
- return true;
- }
-
- //--------------------------------------------------------------
-
- function MouseMove( e) {
-
- var layer = FindLayerByPos( e.pageX,e.pageY,document);
- if ( layer != insideobj) {
- if ( insideobj != null)
- eval( insideobj.name + "_MoveOut( e,layer); ");
- insideobj = layer;
- if ( insideobj != null)
- eval( insideobj.name + "_MoveIn( e,layer); ");
- return usecursor;
- }
- if ( layer != null)
- return usecursor;
- return true;
- }
-
-
- //-----------------------------------------------------------------------------
-
- function FindLayerByPos( x,y,doc) {
-
- var l = doc.layers.length;
- var layer = null;
- for ( var i = 0; i < l; i++) {
- if ( x >= doc.layers[ i].pageX && x <= doc.layers[ i].pageX + doc.layers[ i].clip.width &&
- y >= doc.layers[ i].pageY && y <= doc.layers[ i].pageY + doc.layers[ i].clip.height) {
- var _layer = doc.layers[ i];
- if ( _layer.document.layers.length > 0) {
- var innerlayer = FindLayerByPos( x,y,_layer.document);
- if ( innerlayer != null)
- _layer = innerlayer;
- }
- if ( _layer.name[ 0] != '_')
- layer = _layer;
- }
- }
- return layer;
- }
-
- //-----------------------------------------------------------------------------
-
- function findLayerByName(name, doc) {
-
- var l = doc.layers.length;
- var i;
- var layer;
- for ( i = 0; i < l; i++) {
- layer = doc.layers[i];
- if ( layer.name == name)
- return layer;
- if (layer.document.layers.length > 0) {
- layer = findLayerByName( name, layer.document);
- if (layer != null)
- return layer;
- }
- }
- return null;
- }
-
-
- //-----------------------------------------------------------------------------
-
- function ScrollLayerBy( layer, dy) {
-
- if ( layer == null) return;
- var ct = layer.clip.top;
- var cb = layer.clip.bottom;
-
- if (ct + dy < 0)
- dy = -ct;
- else if (cb + dy > layer.document.height)
- dy = layer.document.height - cb;
-
- layer.clip.top = ct + dy;
- layer.clip.bottom = cb + dy;
- layer.moveBy( 0, -dy);
- }
-
- function ScrollLayerTo( layer,y) {
-
- if ( layer == null) return;
- var dy = y - layer.clip.top;
- ScrollLayerBy( layer,dy);
- }
-
- //-----------------------------------------------------------------------------
-
- function Scroll( layer,dy,delay) {
-
- var innerlayer = layer.parentLayer.document.layers[ 0];
- var paperlayer = layer.parentLayer.document.layers[ 2];
- ScrollLayerBy( innerlayer,dy);
- scrolldy = dy;
- specialobj = layer;
- window.setTimeout( "Scroll_Repeat();",delay);
-
- PositionPaper( paperlayer);
- }
-
- //-----------------------------------------------------------------------------
-
- function Scroll_Repeat() {
-
- if ( specialobj == clickobj && specialobj == insideobj) {
- Scroll( specialobj,scrolldy,100);
- return;
- }
- specialobj = null;
- }
-
- //-----------------------------------------------------------------------------
-
- function StartDragPaper( layer) {
-
- specialobj = layer;
- window.onmousemove = MouseMoveDragPaper;
- window.onmouseup = MouseUpDragPaper;
- }
-
-
- function MouseMoveDragPaper( e) {
-
- var innerlayer = specialobj.parentLayer.document.layers[ 0];
- var buttonheight = specialobj.clip.height;
- var scrollrange = innerlayer.document.height - innerlayer.clip.height;
-
- var y = e.pageY - specialobj.parentLayer.top - buttonheight - buttonheight / 2;
- y = y * scrollrange / (innerlayer.clip.height - 3*buttonheight);
- if ( y < 0) y = 0;
- if ( y > scrollrange) y = scrollrange;
-
- ScrollLayerTo( innerlayer,y);
- PositionPaper( specialobj);
- }
-
-
- function MouseUpDragPaper( e) {
-
- window.onmouseup = MouseUp;
- window.onmousemove = MouseMove;
- specialobj = null;
- }
-
-
- function PositionPaper( paperlayer) {
-
- var innerlayer = paperlayer.parentLayer.document.layers[ 0];
- var buttonheight = paperlayer.clip.height;
- var p = innerlayer.clip.top * 100 / (innerlayer.document.height - innerlayer.clip.height);
- paperlayer.top = buttonheight + p * (innerlayer.clip.height - 3*buttonheight+1) / 100;
- }
-
-
- //-----------------------------------------------------------------------------
-
- function ScrollBarMouseDown( e,layer) {
-
- var y = e.pageY - layer.parentLayer.top;
- var innerlayer = layer.parentLayer.document.layers[ 0];
- var paperlayer = layer.parentLayer.document.layers[ 2];
- var buttonheight = paperlayer.clip.height;
-
- if ( y < buttonheight) {
- Scroll( layer,-12,300);
- layer.parentLayer.document.layers[ 3].visibility="hide";
- layer.parentLayer.document.layers[ 4].visibility="show";
- return;
- }
- if ( y > layer.parentLayer.clip.height - buttonheight) {
- Scroll( layer,12,300);
- layer.parentLayer.document.layers[ 5].visibility="hide";
- layer.parentLayer.document.layers[ 6].visibility="show";
- return;
- }
- if ( y < paperlayer.top) {
- Scroll( layer,-50,300);
- return;
- }
- if ( y > paperlayer.top + buttonheight) {
- Scroll( layer,50,300);
- return;
- }
- StartDragPaper( paperlayer);
- }
-
-
- function ScrollBarMouseUp( e,layer) {
-
- layer.parentLayer.document.layers[ 3].visibility="show";
- layer.parentLayer.document.layers[ 4].visibility="hide";
- layer.parentLayer.document.layers[ 5].visibility="show";
- layer.parentLayer.document.layers[ 6].visibility="hide";
- }
-
- //------------------------------------
-
- function HideAction( obj) {
-
- this.m_Obj = obj;
- this.Start = HideAction_Start;
- }
-
-
- function HideAction_Start() {
-
- this.m_Obj.visibility = "hide";
- }
-
- //------------------------------------
-
-
- function ShowAction( obj) {
-
- this.m_Obj = obj;
- this.Start = ShowAction_Start;
- }
-
-
- function ShowAction_Start() {
-
- this.m_Obj.visibility = "show";
- }
-
- //------------------------------------
-
- function SoundAction( sound,repeat,cancelmidi,cancelwave) {
-
- var pos = sound.lastIndexOf( ".");
- var ext = sound.substring( pos).toLowerCase();
-
- this.m_Sound = sound;
- this.m_Repeat = repeat;
- this.m_CancelMidi = cancelmidi;
- this.m_CancelWave = cancelwave;
- this.m_Midi = ext == ".mid";
-
- this.Start = SoundAction_Start;
- }
-
- function SoundAction_Start() {
-
- if ( window.parent == self || ! canplaysound) return;
-
- if ( this.m_CancelMidi)
- top.global.document.nsplayer1.stop();
- if ( this.m_CancelWave)
- top.global.document.nsplayer2.stop();
-
- if ( this.m_Sound == "") return;
-
- var player = this.m_Midi ? top.global.document.nsplayer1 : top.global.document.nsplayer2;
- player.play( this.m_Repeat,this.m_Sound);
- player.setvol( 100);
- }
-
- //------------------------------------
-
- function SetCursorAction( type) {
-
- this.m_Type = type;
-
- this.Start = SetCursorAction_Start;
- }
-
-
- function SetCursorAction_Start() {
-
- // usecursor = this.m_Type == "hand";
- }
-
- //------------------------------------
-